<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>企业列表 - 测盟汇系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        :root {
            --primary-color: #2c5545;
            --primary-light: #3a7d62;
            --primary-hover: #1e4636;
            --text-color: #333;
            --text-light: #555;
            --border-color: #d1d9d6;
            --bg-light: #f5f7f6;
            --bg-page: #e8ecea;
            --white: #fff;
            --shadow: 0 4px 24px rgba(44, 85, 69, 0.1);
            --radius: 8px;
            --transition: all 0.3s ease;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: var(--bg-page);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: var(--text-color);
            line-height: 1.6;
            padding: 20px;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: var(--white);
            padding: 2rem;
            border-radius: var(--radius);
            box-shadow: var(--shadow);
        }

        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1.5rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid var(--primary-light);
        }

        h1 {
            color: var(--primary-color);
            display: flex;
            align-items: center;
        }

        h1 i {
            margin-right: 0.8rem;
        }

        .back-btn {
            display: inline-block;
            padding: 0.6rem 1rem;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: var(--radius);
            text-decoration: none;
            transition: var(--transition);
            font-size: 0.9rem;
        }

        .back-btn:hover {
            background: var(--primary-hover);
        }

        .add-btn {
            display: inline-block;
            padding: 0.6rem 1rem;
            background: var(--primary-light);
            color: white;
            border: none;
            border-radius: var(--radius);
            text-decoration: none;
            transition: var(--transition);
            font-size: 0.9rem;
            margin-left: 1rem;
        }

        .add-btn:hover {
            background: var(--primary-hover);
        }

        .search-bar {
            display: flex;
            margin-bottom: 1.5rem;
            gap: 1rem;
        }

        .search-bar input {
            flex: 1;
            padding: 0.8rem;
            border: 1px solid var(--border-color);
            border-radius: var(--radius);
            font-size: 1rem;
        }

        .search-bar button {
            padding: 0.8rem 1.5rem;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: var(--radius);
            cursor: pointer;
            transition: var(--transition);
        }

        .search-bar button:hover {
            background: var(--primary-hover);
        }

        .search-bar a.reset-btn {
            padding: 0.8rem 1.5rem;
            background: #6c757d;
            color: white;
            border: none;
            border-radius: var(--radius);
            cursor: pointer;
            transition: var(--transition);
            text-decoration: none;
            display: inline-block;
            text-align: center;
        }

        .search-bar a.reset-btn:hover {
            background: #5a6268;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
        }

        th, td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid var(--border-color);
        }

        th {
            background-color: var(--bg-light);
            color: var(--primary-color);
        }

        tr:hover {
            background-color: var(--bg-light);
        }

        .status-badge {
            display: inline-block;
            padding: 0.3rem 0.6rem;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 500;
        }

        .status-active {
            background: #d4edda;
            color: #155724;
        }

        .status-inactive {
            background: #f8d7da;
            color: #721c24;
        }

        .action-link {
            color: var(--primary-color);
            text-decoration: none;
            margin-right: 10px;
            transition: var(--transition);
        }

        .action-link:hover {
            color: var(--primary-hover);
            text-decoration: underline;
        }

        .action-link.delete {
            color: #d64541;
        }

        .action-link.delete:hover {
            color: #c0392b;
        }

        .footer {
            text-align: center;
            margin-top: 2rem;
            padding: 1rem 0;
            color: var(--text-light);
            font-size: 0.9rem;
        }

        @media (max-width: 768px) {
            .container {
                padding: 1rem;
            }

            th, td {
                padding: 8px 10px;
                font-size: 0.9rem;
            }

            .page-header {
                flex-direction: column;
                align-items: flex-start;
                gap: 1rem;
            }

            .search-bar {
                flex-direction: column;
            }

            .search-bar input,
            .search-bar button,
            .search-bar a.reset-btn {
                width: 100%;
            }
        }
    </style>
</head>
<body>
<div class="container">
    <div class="page-header">
        <h1>
            <i class="fas fa-building"></i>
            企业列表
        </h1>
        <div>
            <a th:href="@{/admin/dashboard}" class="back-btn">
                <i class="fas fa-arrow-left"></i> 返回首页
            </a>
            <a th:href="@{/enterprise/register}" class="add-btn">
                <i class="fas fa-plus"></i> 新增企业
            </a>
        </div>
    </div>

    <!-- 搜索表单 -->
    <form th:action="@{/enterprise/list}" method="get" class="search-bar">
        <input type="text" name="keyword" placeholder="输入企业名称或账号搜索..." th:value="${keyword}">
        <button type="submit">
            <i class="fas fa-search"></i> 搜索
        </button>
        <a th:href="@{/enterprise/list}" class="reset-btn">
            <i class="fas fa-undo"></i> 重置
        </a>
    </form>

    <table>
        <thead>
        <tr>
            <th>ID</th>
            <th>企业名称</th>
            <th>联系方式</th>
            <th>账号</th>
            <th>创建时间</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="enterprise : ${enterprises}">
            <td th:text="${enterprise.id}"></td>
            <td th:text="${enterprise.enterpriseName}"></td>
            <td th:text="${enterprise.contactInfo}"></td>
            <td th:text="${enterprise.account}"></td>
            <td th:text="${#dates.format(enterprise.createTime, 'yyyy-MM-dd HH:mm')}"></td>
            <td>
                <span th:if="${enterprise.status == 1}" class="status-badge status-active">
                    <i class="fas fa-check-circle"></i> 已激活
                </span>
                <span th:if="${enterprise.status == 0}" class="status-badge status-inactive">
                    <i class="fas fa-times-circle"></i> 已禁用
                </span>
            </td>
            <td>
                <a th:href="@{/enterprise/edit/{id}(id=${enterprise.id})}" class="action-link">
                    <i class="fas fa-edit"></i> 编辑
                </a>
                <a th:href="@{/enterprise/delete/{id}(id=${enterprise.id})}" class="action-link delete"
                   onclick="return confirm('确定要删除此企业吗？')">
                    <i class="fas fa-trash-alt"></i> 删除
                </a>
                <a th:href="@{/enterprise/status/{id}/{status}(id=${enterprise.id}, status=${enterprise.status == 1 ? 0 : 1})}"
                   class="action-link">
                    <span th:if="${enterprise.status == 1}">
                        <i class="fas fa-ban"></i> 禁用
                    </span>
                    <span th:if="${enterprise.status == 0}">
                        <i class="fas fa-check"></i> 激活
                    </span>
                </a>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<div class="footer">
    <p>© 2025 测盟汇系统 | 企业管理 | 版本 1.0.0</p>
</div>
</body>
</html>